#pragma once
#include "Game/Process/RenderProcess.h"
#include "Render/Tradition/ComputePipeline.h"
#include "Render/Shader/RHIDescriptor.h"
#include "Render/Tradition/RHIFramebuffer.h"
#include "../LocalEntity.h"
#include "../LocalShader.h"
#include "../ResourceProcess.h"
#include "../LocalScene.h"

class ShadowsAtrousFilterProcess : public RenderProcess
{
	DECLARE_PROCESS(ShadowsAtrousFilterProcess)

	struct PushConstants
	{
		int radius;
		int stepSize;
		float phiVisibility;
		float phiNormal;
		float sigmaDepth;
		float power;
	};

public:

	int32 mFeedbackIteration;

	int32 mFilterIterations;

	float mPower;

	PushConstants mPushConstants;

	int32 mReadIndex;

protected:

	virtual void OnInit() override;

	virtual void OnTick(float deltaTime) override;

	virtual void OnResize() override;

protected:

	LocalScene* mLocalScene;

	ResourceProcess* mResourceProcess;



	RefCountPtr<RHIBuffer> mDenoiseDispatchArgs;

	RefCountPtr<RHIBuffer> mShadowDispatchArgs;



	std::array<RefCountPtr<RHITexture>, 2> mOutputImage;

	RefCountPtr<RHITexture> mHistoryOutputImage;


	RefCountPtr<RHIDescriptor> mCopyDescriptor;

	std::array<DescriptorMask, 2> mCopyDescriptorMask;



	RefCountPtr<RHIDescriptor> mAtrousDescriptor;

	std::array<DescriptorMask, 2> mOutputDescriptorMask;

	std::array<DescriptorMask, 3> mInputDescriptorMask;

	std::array<DescriptorMask, 2> mGBufferDescriptorMask;

	DescriptorMask mCommonDescriptorMask;



	RefCountPtr<ComputePipeline> mCopyPipeline;

	RefCountPtr<ComputePipeline> mAtrousPipeline;




	RefCountPtr<RHICommandBuffer> mCommandBuffer;

	RefCountPtr<RHISemaphore> mWaitGraphicsSemaphore;

	RefCountPtr<RHISemaphore> mSignalComputeSemaphore;

};
